#include<iostream>
#include<vector>
using namespace std;
class Solution {
public:
    bool isValidSudoku(vector<vector<char>>& board) {
        vector<vector<bool>>row(9, vector<bool>(10));
        vector<vector<bool>>col(9, vector<bool>(10));
        vector<vector<vector<bool>>>grid(3, vector<vector<bool>>(3, vector<bool>(10)));
        for (int i = 0; i < 9; i++)
        {
            for (int j = 0; j < 9; j++)
            {
                if (board[i][j] == '.')continue;
                int num = board[i][j] - '0';
                if (row[i][num] != false
                    || col[j][num] != false
                    || grid[i / 3][j / 3][num] != false)
                {
                    return false;
                }
                else
                {
                    row[i][num] = true;
                    col[j][num] = true;
                    grid[i / 3][j / 3][num] = true;
                }
            }
        }
        return true;
    }
};